package
{
	import core.model.ConfigData;
	import core.view.CopyFileView;
	
	import flash.desktop.NativeApplication;
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.filesystem.File;
	import flash.system.Security;
	
	import org.ais.system.Ais;
	import org.aisy.utils.AisyUtils;

	public class Main extends Sprite
	{
		public function Main()
		{
			try {
				Security.allowDomain("*");
				Security.allowInsecureDomain("*");
			} catch (error:Error) {}
			if (!Ais.IMain) {
				Ais.IMain = this;
				connect(this);
			}
		}
		
		public function connect(im:*):void
		{
			if (AisyUtils.isDestop === false) {
				im.Swf.remove(im.Swf.hasSwf("swf", parent));
				return;
			}
			im.stage.align = StageAlign.TOP_LEFT;
			im.stage.scaleMode = StageScaleMode.NO_SCALE;
			
			var url:String = this.loaderInfo.parameters["url"];
			if (!url) url = "CopyFile";
			ConfigData.configUrl = "file:///" + File.applicationDirectory.nativePath + NativeApplication.nativeApplication.openedWindows[0].stage.loaderInfo.url.replace(/^app\:/ig, "").replace(/(.*)(?<=[\\\/]).*/i, "$1") + url;
			ConfigData.readConfigData();
			addChild(CopyFileView.getInstance());
			if (this !== im) im.addChild(this);
			im = null;
			url = null;
		}
		
	}
}